<?php

/**
 * @author игорь
 * @copyright 2009
 */
$com = new CommentWizard;
$action_template = "item";
$db->query("UPDATE $table_games SET hits = hits + 1 WHERE id = '$item_id' LIMIT 1");
$item = $selected_item;
if($item['image'] == '1')
{
	$item['image'] = UPLOAD."flash/".$item_id;
}
else $item['image'] = false;
if($item['file'] == '1')
{
	$filesizes = getimagesize(ROOT_DIR.UPLOAD."flash/".$item_id.".swf");
	if($filesizes != false)
	{
		//print_var($filesizes);
		if(intval($filesizes[0]) > 570)
		{
			$qoeff = 570 / intval($filesizes[0]);
			$new_height = intval(intval($filesizes[1]) * $qoeff);
			$item['filesizes'] = 'width="570" height="'.$new_height.'"';
		}
		else
		{
			$item['filesizes'] = $filesizes[3];
		}
		$item['file'] = UPLOAD."flash/".$item_id.".swf";
	}
	else $item['file'] = false;
}
else $item['file'] = false;
$category = $db->fetch_one("SELECT * FROM $table_category WHERE id = '".$selected_cat_id."'");
$rating['obj_id'] = $item_id;
$rating['module'] = "flash";
$rating['rating'] = $item['rating'];
$rating['rating_text'] = uni_word_end("балл",($item['rating']/1),array("ов","а",""),1);
$rating['votes'] = $item['votes'];
$rating['votes_text'] = uni_word_end("оцен",intval($item['votes']),array("ок","ки","ка"),1);
$rating['hits'] = $item['hits'];
$rating['hits_text'] = uni_word_end("просмотр",intval($item['hits']),array("ов","а",""),1);
$item['hits_text'] = $rating['hits_text'];
if(!$user->user_id)
{
	$is_vote = $db->fetch_one("SELECT id FROM $table_ratings WHERE obj_id = '".$item_id."' AND module = 'flash' AND user_id = '0' AND ip = '$user->ip'");
}
else
{
	$is_vote = $db->fetch_one("SELECT id FROM $table_ratings WHERE obj_id = '".$item_id."' AND module = 'flash' AND user_id = '$user->user_id'");
}
if($is_vote != false and intval($is_vote['id']) != 0)
{
	$uservote = $db->fetch_one("SELECT * FROM $table_ratings WHERE id = '".$is_vote['id']."'");
	$rating['uservote'] = $uservote;
}
$smarty->assign("item",$item);
$smarty->assign("rating",$rating);
$smarty->assign("access_comments",true);
$commentsTree = $com->getCommentsTree('flash',$item['id']);
$comments = $commentsTree;
$comments['source'] = SITE_URL.$this->full_alias.$item['alias'].".html";
$comments['obj_id'] = $item['id'];
$comments['module'] = 'flash';
$com->setRandomNumbers();
$smarty->assign("comments",$comments);
$this->adress_string[] = array(
	'title' =>$category['title'],
	'menu_title' =>$category['title'],
	'alias' => SITE_URL.$this->full_alias."cat_".$category['alias']."/"
);
$this->adress_string[] = array(
	'title' =>$item['title'],
	'menu_title' =>$item['title'],
	'alias' => SITE_URL.$this->full_alias.$item['alias'].".html"
);
$header = $item['title'].". Флеш ".$cat['title'];
$smarty->assign("header",$header);
$this->info['title'] = $header.". ".$this->info['title'];
?>